package com.bjsj.pro.view.dialogflm;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.bjsj.pro.R;


/**
 * 确定样式Dialog
 */
public class ConfirmDialog extends BaseDialog {

    private String title;
    private String msg;
    public static ConfirmDialog newInstance(String title, String msg, OnqudingCallBack callBack) {
        Bundle bundle = new Bundle();
        bundle.putString("title", title);
        bundle.putString("msg", msg);
        ConfirmDialog dialog = new ConfirmDialog();
        dialog.setArguments(bundle);
        dialog.setMargin(50);
        dialog.setOutCancel(false);
        dialog.setOnqudingCallBack(callBack);
        return dialog;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle == null) {
            return;
        }
        title = bundle.getString("title");
        msg = bundle.getString("msg");
    }

    @Override
    public int setUpLayoutId() {
        return R.layout.dialog_confirm;
    }

    @Override
    public void convertView(DialogViewHolder holder, final BaseDialog dialog) {
        holder.setText(R.id.title, title);
        holder.setText(R.id.message, msg);


        holder.setOnClickListener(R.id.cancel, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        holder.setOnClickListener(R.id.confirm, new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                if(onqudingCallBack!=null)
                {
                    onqudingCallBack.onQueding(dialog);
                }
            }
        });




    }


    public interface OnqudingCallBack
    {
        void  onQueding(BaseDialog dialog);
    }

    public OnqudingCallBack  onqudingCallBack;

    public void setOnqudingCallBack(OnqudingCallBack onqudingCallBack)
    {
        this.onqudingCallBack = onqudingCallBack;
    }
}
